package com.lipaluma.field.adaptor.builder;

import com.lipaluma.field.adaptor.impl.StringReplaceAdaptor;
import com.lipaluma.field.adaptor.impl.TrimAdaptor;
import com.lipaluma.field.adaptor.impl.TruncateAdaptor;
import com.lipaluma.field.mapper.FieldAdaptedOnEachValue;
import com.lipaluma.field.mapper.builder.FieldMapperAfterRegisterBuilder;
import com.lipaluma.field.mapper.builder.FieldMapperBuilder;

public class AdaptorOnEachValueBuilder {

	private FieldMapperBuilder parent;
	private FieldAdaptedOnEachValue fieldAdapted;

	public AdaptorOnEachValueBuilder(FieldMapperBuilder parent, FieldAdaptedOnEachValue fieldAdapted) {
		this.parent = parent;
		this.fieldAdapted = fieldAdapted;
	}

	public AdaptorOnEachValueBuilder trim(){
		fieldAdapted.addNewAdaptorOnEachValue(new TrimAdaptor());
		return this;				
	}

	public AdaptorOnEachValueBuilder replace(String toFind, String replacement){
		fieldAdapted.addNewAdaptorOnEachValue(new StringReplaceAdaptor(toFind, replacement));
		return this;				
	}

	public AdaptorOnEachValueBuilder truncateAt(int maxSize){
		fieldAdapted.addNewAdaptorOnEachValue(new TruncateAdaptor(maxSize));
		return this;				
	}

	public AdaptorOnEachValueBuilder truncateAt(int maxSize, String suffix){
		fieldAdapted.addNewAdaptorOnEachValue(new TruncateAdaptor(maxSize, suffix));
		return this;				
	}
	
	public FieldMapperAfterRegisterBuilder end(){
		return parent;
	}
}
